package com.mtf.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mtf.entity.MtfStock;
import com.mtf.mapper.MtfStockMapper;
import com.mtf.service.IMtfStockService;
import org.springframework.stereotype.Service;

/**
 * @Description: mtf_stock
 * @Author: jeecg-boot
 * @Date:   2023-11-02
 * @Version: V1.0
 */
@Service
public class MtfStockServiceImpl extends ServiceImpl<MtfStockMapper, MtfStock> implements IMtfStockService {

    @Override
    public boolean checkStockByProductIdentity(String productIdentity, Integer num) {
        Integer stockNum = this.baseMapper.selectStockNumByProductIdentity(productIdentity);
        return stockNum.compareTo(num) > -1;
        //return stockNum > num;
    }

    @Override
    public void substractStockByProductIdentity(String productIdentity, Integer num) {
        this.baseMapper.updateStockNumByProductIdentity(productIdentity,num);
    }
}
